package com.sun.lg.utils;

import com.sun.lg.anno.Component;

import java.sql.Connection;
import java.sql.SQLException;

@Component
public class ConnectionUtils {

    private ThreadLocal<Connection> threadLocal = new ThreadLocal();

    public Connection getCurreentThreadConnection() throws SQLException {
        Connection connection = threadLocal.get();
        if(connection == null){
            connection = DruidUtils.getInstance().getConnection();
            threadLocal.set(connection);
        }
        return connection;
    }

}
